package com.ustb.hospital.servlet;

import com.github.pagehelper.PageInfo;
import com.ustb.hospital.entity.Departments;
import com.ustb.hospital.service.DepartmentsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/list")
public class DepartmentsListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String pageNum=req.getParameter("pageNum");
        String pageSize=req.getParameter("pageSize");
        int i=1;
        if(pageNum!=null && pageNum!=""){
            i=Integer.parseInt(pageNum);
        }
        //数据类型转换 String->int
        //int i=Integer.parseInt(pageNum);
        //int j=Integer.parseInt(pageSize);

        DepartmentsServiceImpl service =new DepartmentsServiceImpl();
        //List<Departments> list=service.queryAll();
        PageInfo pageInfo=service.queryAll(i,5); ////

        req.setAttribute("pageInfo",pageInfo);
        req.getRequestDispatcher("/dept/list.jsp").forward(req,resp);
    }
    //dopost 另一个方法
}
